package Timesheet;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import oracle.adfmf.java.beans.PropertyChangeListener;
import oracle.adfmf.java.beans.PropertyChangeSupport;

public class TimesheetDailyReport {
	private int sheetID;
	private int sheetSeq;
	private int periodSeq;
	private Date dateUnderReport;

	private double scheduledQuantity;
	private double totalReportedQuantity;
	private String reportedStatus;
	private String comment;

	/**
	 * @associates <{Timesheet.TimesheetDailyReportLine}>
	 */
	private ArrayList tsLines = new ArrayList();
	private TimesheetDailyReportLine editTsLine = new TimesheetDailyReportLine();
	private transient PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
			this);

	public TimesheetDailyReport() {
		super();
	}

	public TimesheetDailyReport(int sheetID, int sheetSeq, int periodSeq,
			Date dur, String reportedStatus, double scheduledQty,
			double totalReportedQty, String comment) {
		super();
		this.sheetID = sheetID;
		this.sheetSeq = sheetSeq;
		this.periodSeq = periodSeq;
		this.dateUnderReport = dur;
		this.reportedStatus = reportedStatus;
		this.scheduledQuantity = scheduledQty;
		this.totalReportedQuantity = totalReportedQty;
		this.comment = comment;
		if (this.tsLines == null) {
			this.tsLines = new ArrayList();
		}
		this.tsLines.add(new TimesheetDailyReportLine(this.sheetID,
				this.sheetSeq, this.periodSeq, (Calendar.getInstance()
						.getTime()), 0, 0, "TaskGroup", "trc", "Billable",
				"projectID", "activityID", "comment"));// XXX Debug
	}

	public void cloneFrom(TimesheetDailyReport srcDailyReport) {// TODO
	}

	public String newLine() {
		// TODO
		String newSeqNbr = "";
		return newSeqNbr;
	};

	public void editLine(String seqNbr) {
		// TODO
	};

	public boolean deleteLine(String seqNbr) {
		// TODO
		return true;
	};

	public boolean saveLine(String seqNbr) {
		// TODO
		return true;
	};

	public boolean cancelLine(String seqNbr) {
		// TODO
		return true;
	};

	public void addPropertyChangeListener(PropertyChangeListener l) {
		propertyChangeSupport.addPropertyChangeListener(l);
	}

	public void removePropertyChangeListener(PropertyChangeListener l) {
		propertyChangeSupport.removePropertyChangeListener(l);
	}

	public TimesheetDailyReportLine[] getTsLines() {
		return (TimesheetDailyReportLine[]) tsLines
				.toArray(new TimesheetDailyReportLine[tsLines.size()]);
	}

	public void setDateUnderReport(Date dateUnderReport) {
		Date oldDateUnderReport = this.dateUnderReport;
		this.dateUnderReport = dateUnderReport;
		propertyChangeSupport.firePropertyChange("dateUnderReport",
				oldDateUnderReport, dateUnderReport);
	}

	public Date getDateUnderReport() {
		return dateUnderReport;
	}

	public void setTotalReportedQuantity(double totalReportedQuantity) {
		double oldTotalReportedQuantity = this.totalReportedQuantity;
		this.totalReportedQuantity = totalReportedQuantity;
		propertyChangeSupport.firePropertyChange("totalReportedQuantity",
				oldTotalReportedQuantity, totalReportedQuantity);
	}

	public double getTotalReportedQuantity() {
		return totalReportedQuantity;
	}

	public void setReportedStatus(String reportedStatus) {
		String oldReportedStatus = this.reportedStatus;
		this.reportedStatus = reportedStatus;
		propertyChangeSupport.firePropertyChange("reportedStatus",
				oldReportedStatus, reportedStatus);
	}

	public String getReportedStatus() {
		return reportedStatus;
	}

	public void setEditTsLine(TimesheetDailyReportLine editTsLine) {
		TimesheetDailyReportLine oldEditTsLine = this.editTsLine;
		this.editTsLine = editTsLine;
		propertyChangeSupport.firePropertyChange("editTsLine", oldEditTsLine,
				editTsLine);
	}

	public TimesheetDailyReportLine getEditTsLine() {
		return editTsLine;
	}

	public void setTsLines(ArrayList tsLines) {
		ArrayList oldTsLines = this.tsLines;
		this.tsLines = tsLines;
		propertyChangeSupport
				.firePropertyChange("tsLines", oldTsLines, tsLines);
	}

	public void setScheduledQuantity(double scheduledQuantity) {
		double oldScheduledQuantity = this.scheduledQuantity;
		this.scheduledQuantity = scheduledQuantity;
		propertyChangeSupport.firePropertyChange("scheduledQuantity",
				oldScheduledQuantity, scheduledQuantity);
	}

	public double getScheduledQuantity() {
		return scheduledQuantity;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getComment() {
		return comment;
	}

	public void setSheetID(int sheetID) {
		this.sheetID = sheetID;
	}

	public int getSheetID() {
		return sheetID;
	}

	public void setSheetSeq(int sheetSeq) {
		this.sheetSeq = sheetSeq;
	}

	public int getSheetSeq() {
		return sheetSeq;
	}

	public void setPeriodSeq(int periodSeq) {
		this.periodSeq = periodSeq;
	}

	public int getPeriodSeq() {
		return periodSeq;
	}
}
